package com.itsu.mongodb.service.impl;

import com.itsu.interfaces.entity.UserLike;
import com.itsu.interfaces.service.UserLikeService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@Service
public class UserLikeServiceImpl implements UserLikeService {

    @Autowired
    MongoTemplate mongoTemplate;


    @Override
    public void saveUserLike(UserLike userLike) {
        mongoTemplate.insert(userLike);
    }

    @Override
    public List<UserLike> findLikeList(Long uid) {
        return mongoTemplate.find(Query.query(Criteria.where("userId").is(uid)),UserLike.class);
    }

    @Override
    public List<UserLike> findFanList(Long likeUid) {
        return mongoTemplate.find(Query.query(Criteria.where("likeUserId").is(likeUid)),UserLike.class);
    }
}
